<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.dic.dao.model.*" %>
<%@ page import="com.dic.service.*" %>

<%
   System.out.println(" yes");
   request.setCharacterEncoding("utf-8");
   response.setCharacterEncoding("utf-8");
   String username=request.getParameter("username");
   String password=request.getParameter("password");
   String role=request.getParameter("role");
   
   HashMap<String,String> hm=new HashMap<String,String>();
   hm.put("username", username);
   hm.put("role", role);
   
   User user1=new User(username,password,role);
   UserService ser1 = new UserService();
   User user2=ser1.checkExist2(hm);
   boolean isExist=false;
   if(user2==null){
      isExist=false;//数据库中无此用户
   }else{
      isExist=true;//该用户已存在
   }

   if(isExist==false){
      UserService ser2 = new UserService();
      int insertflag=ser2.insertUser(user1);
      if(insertflag==1){
          out.print("{'result':'success'}");
      }else{
          out.print("{'result':'fail'}");
      }
   }else{
      out.print("{'result':'failp'}");
   }
   
   
   
   
%>